# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=nettle
pkgver=3.10
pkgrel=1
pkgdesc="Low-level cryptographic library"
url="https://www.lysator.liu.se/~nisse/nettle/"
arch="all"
license="GPL-2.0-or-later OR LGPL-3.0-or-later"
depends_dev="gmp-dev"
makedepends="$depends_dev m4"
subpackages="$pkgname-static $pkgname-dev $pkgname-utils"
source="https://ftp.gnu.org/gnu/nettle/nettle-$pkgver.tar.gz"

# secfixes:
#   3.7.3-r0:
#     - CVE-2021-3580
#   3.7.2-r0:
#     - CVE-2021-20305

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-fat \
		--enable-shared \
		--disable-openssl \
		--enable-static
	make
	# strip comments in fields from .pc as it confuses pkgconf
	sed -i -e 's/ \#.*//' ./*.pc
}

check() {
	make -C examples # required for rsa-encrypt
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Utils for nettle"
	amove usr/bin
}

sha512sums="
18d5b904ce60514aa81b57bff2945e5f7f4366d4775e6a5ffc227b85be2def72b3d2159b983b75ac95a56d3167a2ef1a25b5dfc2fb6193f16a012935c36a7b34  nettle-3.10.tar.gz
"
